import request from "@/utils/service";
import resource from "@/utils/resource";
export default {
  get: async ({ page, limit, query }) => {
    return await request({
      url: "/goods",
      method: "get",
      params: {
        page,
        limit,
        query: JSON.stringify(query)
      }
    });
  },
  getOne: async _id => {
    return await request({
      url: "/goods/" + _id,
      method: "get"
    });
  },
  changeStatus: async ({ status, _id }) => {
    return await request({
      url: "/goods/" + _id,
      method: "patch",
      data: { status }
    });
  },
  update: async goods => {
    return await request({
      url: "/goods/" + goods._id,
      method: "put",
      data: goods
    });
  },
  add: async goods => {
    return await request({
      method: "post",
      url: "/goods",
      data: goods
    });
  },
  delImg: async url => {
    return await resource({
      url: "/goods/delImg",
      method: "delete",
      data: { url }
    });
  },
  updateImgT: async imgFile => {
    return await resource({
      url: "/goods/updateImg",
      method: "post",
      data: { imgFile }
    });
  }
};
